gridpack::math::BaseMatrixInterface< T, I > Class Template Reference

Abstract interface for matrix classes. More...

#include <matrix_interface.hpp>

Inheritance diagram for gridpack::math::BaseMatrixInterface< T, I >:
Inheritance graph
[legend]
Collaboration diagram for gridpack::math::BaseMatrixInterface< T, I >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef T TheType
typedef I IdxType

Public Member Functions

 BaseMatrixInterface (void)
 Default constructor.
 ~BaseMatrixInterface (void)
 Destructor.
void localRowRange (IdxType &lo, IdxType &hi) const
 Get the global index range of the locally owned rows.
IdxType rows (void) const
 Get the total number of rows in this matrix.
IdxType localRows (void) const
 Get the number of local rows in this matirx.
IdxType cols (void) const
 Get the number of columns in this matrix.
IdxType localCols (void) const
 Get the number of local columns in this matirx.
void setElement (const IdxType &i, const IdxType &j, const TheType &x)
 Set an individual element.
void setElements (const IdxType &n, const IdxType *i, const IdxType *j, const TheType *x)
 Set an several elements.
void addElement (const IdxType &i, const IdxType &j, const TheType &x)
 Add to an individual element.
void addElements (const IdxType &n, const IdxType *i, const IdxType *j, const TheType *x)
 Add to an several elements.
void getElement (const IdxType &i, const IdxType &j, TheType &x) const
 Get an individual element.
void getElements (const IdxType &n, const IdxType *i, const IdxType *j, TheType *x) const
 Get an several elements.
void getRow (const IdxType &row, TheType *x) const
 Get a row and put it in a local array.
void getRowBlock (const IdxType &nrow, const IdxType *rows, TheType *x) const
 Get some rows and put them in a local array.
void identity (void)
 Make this matrix the identity matrix.
void addDiagonal (const TheType &x)
 Shift the diagonal of this matrix by the specified value.
void scale (const TheType &x)
 Scale this entire MatrixT by the given value.
void real (void)
 Replace all elements with their real parts.
void imaginary (void)
 Replace all elements with their imaginary parts.
void conjugate (void)
 Replace all elements with their complex gradient.
double norm2 (void) const
 Compute the matrix L2 norm.
void zero (void)
 Zero all entries in the matrix.
void ready (void)
 Indicate the matrix is ready to use.
void print (const char *filename=NULL) const
 Print to named file or standard output.
void save (const char *filename) const
 Save, in MatLAB format, to named file (collective).
void loadBinary (const char *filename)
 Load from a named file of whatever binary format the math library uses.
void saveBinary (const char *filename) const
 Save to named file in whatever binary format the math library uses.

Detailed Description

template<typename T, typename I = int>
class gridpack::math::BaseMatrixInterface< T, I >

Abstract interface for matrix classes.


Member Typedef Documentation

template<typename T, typename I = int>
typedef I gridpack::math::BaseMatrixInterface< T, I >::IdxType

The size/index type used.

Reimplemented in gridpack::math::MatrixT< T, I >.

template<typename T, typename I = int>
typedef T gridpack::math::BaseMatrixInterface< T, I >::TheType

The numeric type used.

Reimplemented in gridpack::math::MatrixT< T, I >.


Constructor & Destructor Documentation

template<typename T, typename I = int>
gridpack::math::BaseMatrixInterface< T, I >::BaseMatrixInterface ( void   ) 

Default constructor.

template<typename T, typename I = int>
gridpack::math::BaseMatrixInterface< T, I >::~BaseMatrixInterface ( void   ) 

Destructor.


Member Function Documentation

template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::addDiagonal ( const TheType x  ) 

Shift the diagonal of this matrix by the specified value.

Collective.

Parameters:
x 
template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::addElement ( const IdxType i,
const IdxType j,
const TheType x 
)

Add to an individual element.

Local.

Parameters:
i global, 0-based row index
j global, 0-based column index
x value to add to matrix element
template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::addElements ( const IdxType n,
const IdxType i,
const IdxType j,
const TheType x 
)

Add to an several elements.

Local.

Parameters:
n number of elements to update
i array of n global, 0-based row indexes
j array of n global, 0-based column indexes
x array of n values to add to existing matrix elements
template<typename T, typename I = int>
IdxType gridpack::math::BaseMatrixInterface< T, I >::cols ( void   )  const

Get the number of columns in this matrix.

Local.

Returns:
number of columns in matrix
template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::conjugate ( void   ) 

Replace all elements with their complex gradient.

template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::getElement ( const IdxType i,
const IdxType j,
TheType x 
) const

Get an individual element.

Local.

Only local elements may be retrieved using this method.

Parameters:
i global, 0-based row index
j global, 0-based column index
x variable in which to place retrieved value
template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::getElements ( const IdxType n,
const IdxType i,
const IdxType j,
TheType x 
) const

Get an several elements.

Local.

Only local elements may be retrieved using this method.

Parameters:
n number of elements to retrieve
i array of n global, 0-based row indexes
j array of n global, 0-based column indexes
x array of n values in which retrieved values are to be placed
template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::getRow ( const IdxType row,
TheType x 
) const

Get a row and put it in a local array.

template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::getRowBlock ( const IdxType nrow,
const IdxType rows,
TheType x 
) const

Get some rows and put them in a local array.

(Collective)

This gets the elements in the specified rows and puts them in the specified array. It is assumed that the array is appropriately sized (nrow * columns). While this is collective, each processor may get a different set of rows. Row/column ownership should not matter.

Parameters:
nrow 
rows 
x 
template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::identity ( void   ) 

Make this matrix the identity matrix.

Collective

template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::imaginary ( void   ) 

Replace all elements with their imaginary parts.

template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::loadBinary ( const char *  filename  ) 

Load from a named file of whatever binary format the math library uses.

Collective.

The underlying math library generally supports some way to save a matrix to a file. This will load elements from a file of that format.

Parameters:
filename 
template<typename T, typename I = int>
IdxType gridpack::math::BaseMatrixInterface< T, I >::localCols ( void   )  const

Get the number of local columns in this matirx.

template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::localRowRange ( IdxType lo,
IdxType hi 
) const

Get the global index range of the locally owned rows.

Local.

Parameters:
lo first (0-based) index of locally owned rows
hi one more than the last (0-based) index of locally owned rows
template<typename T, typename I = int>
IdxType gridpack::math::BaseMatrixInterface< T, I >::localRows ( void   )  const

Get the number of local rows in this matirx.

Local.

Returns:
number of rows owned by this process
template<typename T, typename I = int>
double gridpack::math::BaseMatrixInterface< T, I >::norm2 ( void   )  const

Compute the matrix L2 norm.

Collective.

The vector L2, or Euclidian, norm is computed as

\[ \left\| \mathbf{A} \right\| ~ = ~ \sqrt{\sum_{ij} A_{ij}^{2}} \]

Returns:
L2 norm of this matrix
template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::print ( const char *  filename = NULL  )  const

Print to named file or standard output.

Collective.

The format is dependent on the specific vector implementation.

Parameters:
filename optional file
template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::ready ( void   ) 

Indicate the matrix is ready to use.

Collective.

This is used to indicate that the matrix is ready to use. This must be called after all setElement() or addElement() calls and before the vector is used for any operation.

template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::real ( void   ) 

Replace all elements with their real parts.

template<typename T, typename I = int>
IdxType gridpack::math::BaseMatrixInterface< T, I >::rows ( void   )  const

Get the total number of rows in this matrix.

Local.

Returns:
total number of rows
template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::save ( const char *  filename  )  const

Save, in MatLAB format, to named file (collective).

Collective.

Parameters:
filename 
template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::saveBinary ( const char *  filename  )  const

Save to named file in whatever binary format the math library uses.

Collective.

The underlying math library generally supports some way to save a matrix to a file. This routine uses whatever format that can be read by loadBinary().

Parameters:
filename 
template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::scale ( const TheType x  ) 

Scale this entire MatrixT by the given value.

Collective.

Parameters:
x factor by which all elements in the matrix are multiplied
template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::setElement ( const IdxType i,
const IdxType j,
const TheType x 
)

Set an individual element.

Local.

This overwrites the value at the specified i row and j column. ready() must be called after all setElement() calls and before using the matrix.

Parameters:
i global (0-based) row index
j global (0-based) column index
x value to place in matrix
template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::setElements ( const IdxType n,
const IdxType i,
const IdxType j,
const TheType x 
)

Set an several elements.

Local.

This overwrites values at several locations in the matrix. ready() must be called after all setElements() calls and before using the matrix.

Parameters:
n number of values to place in
i array of n global, 0-based row indexes
j array of n global, 0-based column indexes
x array of n values to replace existing matrix elements
template<typename T, typename I = int>
void gridpack::math::BaseMatrixInterface< T, I >::zero ( void   ) 

Zero all entries in the matrix.

Collective.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 3 Feb 2020 for GridPACK by  doxygen 1.6.1